package com.imdroid.carac.net;

import com.imdroid.carac.activities.HomeActivity;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.SendMessageToWX;
import com.tencent.mm.sdk.openapi.SendMessageToWX.Req;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
import com.tencent.mm.sdk.openapi.WXImageObject;
import com.tencent.mm.sdk.openapi.WXMediaMessage;
import com.tencent.mm.sdk.openapi.WXTextObject;

// 需要已经安装微信

public class Weixin {


	
	
private static final String appId = "wxe7a4d64bc2cfa3de";
private static IWXAPI api;

//public static void init() {
//}




public static void send( String pic ) {
	if( api == null ) {
		api = WXAPIFactory.createWXAPI( HomeActivity.getInstance(), appId, false );
		api.registerApp( appId );
	}

	WXImageObject obj = new WXImageObject();
	obj.setImagePath( pic );

	WXMediaMessage msg = new WXMediaMessage();
	msg.mediaObject = obj;
	msg.description = "test2"; // 尚未发现用处
	msg.title = "test1"; // 尚未发现用处

	SendMessageToWX.Req req = new SendMessageToWX.Req();
	req.transaction = ""+System.currentTimeMillis();
	req.message = msg;
	req.scene = Req.WXSceneTimeline;

	api.sendReq( req );
}

public static void test() {
	WXTextObject obj = new WXTextObject();
	obj.text = "xxxxxxxxxxxxxxxxxxx";

	WXMediaMessage msg = new WXMediaMessage();
	msg.mediaObject = obj;
	msg.description = "test2"; // 尚未发现用处
//	msg.title = "test1"; // 尚未发现用处

	SendMessageToWX.Req req = new SendMessageToWX.Req();
	req.transaction = ""+System.currentTimeMillis();
	req.message = msg;
//	req.scene = req.WXSceneTimeline;

	api.sendReq( req );
}



}
